import { HttpException, Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { PlotsEntity } from "./plot.entity";
export interface PlotsRo {
    list: PlotsEntity[];
    count: number;
}
@Injectable()
export class PlotsService {
    constructor( @InjectRepository(PlotsEntity)
    private readonly plotsRepository: Repository<PlotsEntity>,){}
      // 获取小区列表
    async findAll(query): Promise<PlotsRo> {
        const list = await this.plotsRepository.find()
        const count = await this.plotsRepository.count();
        return { list: list, count: count };
    }
    async getplotsNamebyId(body:any) {
        const plotId = body.plotId
        const res = await this.plotsRepository.findOne({
            where:{
                id:plotId
            }
        })
        if (res) {
            return {
                status:0,
                data:res.name
            }
        }
    }
}